package com.kmdd.xtds.ui

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.kmdd.xtds.configs.BloodRecord
import com.kmdd.xtds.configs.Cover
import com.kmdd.xtds.configs.PrefsManager
import com.kmdd.xtds.databinding.ActivityBloodRecordAddBinding
import com.kmdd.xtds.databinding.ActivityCoverProfileBinding
import com.kmdd.xtds.room.BloodPressureDatabase
import com.kmdd.xtds.toast
import com.kmdd.xtds.util.emptyReplaceDefault
import com.kmdd.xtds.util.launch
import com.gyf.immersionbar.ktx.immersionBar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.withContext

class CoverProfileActivity : AppCompatActivity() {

    private lateinit var binding: ActivityCoverProfileBinding

    companion object {

        fun start(context: Context, cover: Cover) {
            context.startActivity(Intent(context, CoverProfileActivity::class.java).apply {
                putExtra("cover", cover)
            })

        }

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityCoverProfileBinding.inflate(layoutInflater)
        setContentView(binding.root)
        immersionBar {
            transparentBar()
            keyboardEnable(true)
            fitsSystemWindows(false)
            statusBarDarkFont(false)
        }

        val cover = intent.getSerializableExtra("cover") as Cover

        binding.ivCover.setImageResource(cover.coverId)
        binding.tvContent.text = cover.content
        binding.frameLayoutBack.setOnClickListener {
            finish()
        }
    }
}